// import Connector from "./Connector";
import Avatar from "./Avatar";
import PointRoom from "./PointRoom";
import PoolRoom from "./PoolRoom";
import DealRoom from "./DealRoom";
import PrivateRoom from "./PrivateRoom";
import ws from "../Managers/GameWS";

const EN_CLASS = new Map();
// EN_CLASS.set('Connector', Connector)
EN_CLASS.set('Avatar', Avatar);
EN_CLASS.set('PointRoom', PointRoom);
EN_CLASS.set('DealRoom', DealRoom);
EN_CLASS.set('PoolRoom', PoolRoom);
EN_CLASS.set('PrivateRoom', PrivateRoom);

class EntityMng {

    // create(en_class, id, props) {
    //     console.log('create entity', en_class, props);
    //     let TEMP = EN_CLASS.get(en_class);
    //     let entity = new TEMP(id, ws);
    //     props.forEach(prop => {
    //         entity[prop.name] = prop.value;
    //     });
    //     cc.log("创建新的entity:",entity)
    //     return entity;
    // }

    create(en_class, props, world) {
        let TEMP = EN_CLASS.get(en_class);
        let entity = new TEMP(props.id, world);
        let keys = Object.keys(props);
        keys.forEach(key => {
            entity[key] = props[key];
        });
        return entity;
    }
}

export default new EntityMng();